#include<iostream>
using namespace std;
int main()
{
	int n;
	long long a[40] = { 0,2 };
	for (int w = 2; w <= 35; w++)
	{
		a[w] = a[w - 1] * 3 + 2;
	}
	while (cin >> n && n)
	{
		cout << a[n] << endl;
	}
	return 0;
}